package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;

/**
 * Created by windo on 16/8/4.
 */
public class UpdateUserInfoTask extends CouponHttpBaseTask {
    private String mSchool;
    private String mGrade;
    private String mClassName;
    private String mRealNmae;
    private String mSex;
    private String mNickName;
    private String mUserSign;
    private String mKemu;
    private String mArea;
    private String mCla;


    public UpdateUserInfoTask(String school, String grade, String real, String sex, String nickName, String userSign, String kemu, String area,String cla) {
        mSchool = school;
        mGrade = grade;
        mRealNmae = real;
        mSex = sex;
        mNickName = nickName;
        mUserSign = userSign;
        mKemu = kemu;
        mArea = area;
        mCla = cla;
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest();
            request.setApiNo(ApiNo.UPDATEUSERINFO);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("schoolName", mSchool);
            jsonObject.put("belongGrade", mGrade);
            jsonObject.put("trueName", mRealNmae);
            jsonObject.put("sex", mSex);
            jsonObject.put("nickName", mNickName);
            jsonObject.put("userSign", mUserSign);
            jsonObject.put("subject", mKemu);
            jsonObject.put("area", mArea);
            jsonObject.put("cla", mCla);
            request.setData(jsonObject.toString());
            addRequest(request);
        }
    }

    @Override
    protected void processResponseData(CouponHttpResponse response) {
        notifyTaskCompleted(TaskResultCode.SUCCESS, null);
    }
}
